<?php
/**
 * Created by PhpStorm.
 * User: lyon
 * Date: 16-12-6
 * Time: 下午12:41
 */
class ReadUserInfo
{
    protected $pdo;
    public function __construct()
    {
        $this->pdo = new PDO("mysql:host=127.0.0.1;dbname=weibo;charset=utf8", "root", "lfding");
    }
    public function getOneUserName()
    {
        $sql = "SELECT * FROM `weibo_zombie` WHERE `issearch` = 0 LIMIT 1";
        $result = $this->pdo->query($sql);
        $uName = $result->fetch();
        $this->setUserStatus(1, $uName['id']);
        return $uName;
    }
    public function setUserStatus($is_search = 0, $id = 0)
    {
        $sql = "UPDATE `weibo_zombie` SET `issearch` = $is_search WHERE `id` = $id";
        if ($this->pdo->exec($sql))
        {
            return true;
        }else {
            return false;
        }
    }
}